Skip to content

feat(batch): async batch processing with worker pool (#11)#71

Merged
Siddhant-K-code merged 1 commit into
mainfrom
feat/11-batch-api
May 2, 2026
Merged

feat(batch): async batch processing with worker pool (#11)#71
Siddhant-K-code merged 1 commit into
mainfrom
feat/11-batch-api

Conversation

@Siddhant-K-code
Copy link
Copy Markdown
Owner

Closes #11

Summary

Adds pkg/batch — an in-memory async job processor for large deduplication workloads.

API

# Submit
POST /v1/batch
{"chunks":[...],"options":{"dedup":{"enabled":true},"compress":{"enabled":true}}}
→ {"job_id":"batch_1234","status":"queued"}

# Poll
GET /v1/batch/batch_1234
→ {"status":"processing","progress":0.45,"started_at":"..."}

# Results
GET /v1/batch/batch_1234/results
→ {"chunks":[...],"stats":{"original_tokens":5000,"final_tokens":1200,...}}

pkg/batch

  • Processor: configurable worker pool (default 4), job queue (default 1000), result TTL (default 24h)
  • Submit: enqueues job, returns immediately
  • Get: current job state (queued / processing / completed / failed)
  • Results: deduplicated chunks + pipeline stats for completed jobs
  • List(status): filter jobs by status
  • evictLoop: background goroutine removes expired results every 5 minutes
  • Stop: graceful shutdown

HTTP handlers are in cmd/api_pipeline.go (part of feat/4-pipeline).

Files

  • pkg/batch/batch.go
  • pkg/batch/batch_test.go — 7 tests

@Siddhant-K-code Siddhant-K-code added the enhancement New feature or request label May 2, 2026
Implements issue #11. Adds pkg/batch:

- Processor: in-memory job queue backed by a configurable worker pool
- Submit: enqueues a job, returns immediately with job_id
- Get: returns current job state (queued/processing/completed/failed)
- Results: returns deduplicated chunks + pipeline stats for completed jobs
- List: filter jobs by status
- evictLoop: removes completed/failed jobs after ResultTTL (default 24h)
- Stop: graceful shutdown, drains in-flight jobs

HTTP handlers live in cmd/api_pipeline.go (part of feat/4-pipeline).

Co-authored-by: Ona <no-reply@ona.com>
@Siddhant-K-code Siddhant-K-code merged commit 68f7248 into main May 2, 2026
@Siddhant-K-code Siddhant-K-code deleted the feat/11-batch-api branch May 2, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Batch API Endpoint

1 participant